Parser assignment
Description
Grammar definition
Test programs
Description
Write the parser, the second phase of your compiler. The parser should
use your previous scanner to read all tokens of an input program and check
whether the program is grammatically correct. The specific requirements
are:
-
As in the scanner project, your parser should ignore (but copy) "meta-statements"
at the beginningof the program.
-
The grammer definition is here. Regardless the
choice of your implementation, you must convert the grammar into an LL(1)
grammar and submit the modified grammar in writing.
-
For each input program, your parser should report "Pass" or "Fail" as the
result of grammar analysis. It suffices to include only one of these
two words in the output (stdout) of your program.
Additional requirement
Count the number of variables, functions (<func>), and statements (<statement>)
in correct programs. Output the result in the following format: variable
_num_variables function _num_functions statement _num_statements.
For example, for a correct program with 4 variables, 2 functions and 6
statements, your compiler should output at least the following:
Pass variable 4 function 2 statement 6
Test programs
A list of 8 standard test programs can be downloaded
from here. Scroll down to see the content of README.